package fr.ralmn.OgameDroid.Frame;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import fr.ralmn.OgameDroid.R;
import fr.ralmn.OgameDroid.TechnoActivity;
import fr.ralmn.OgameDroid.TechnoListActivity;
import fr.ralmn.OgameDroid.Util;
import fr.ralmn.OgameDroid.Object.Batiment;
import fr.ralmn.OgameDroid.Object.Objects;
import fr.ralmn.OgameDroid.Object.Technologie;
import fr.ralmn.OgameDroid.list.Adapter.RequireTArrayAdapter;
import fr.ralmn.OgameDroid.list.Adapter.TechoArrayAdapter;

public class Ressource_techno extends ListFragment {

	public static Batiment technologie = Objects.metal;
	private int LEVEL = 1;
	public static TechnoActivity ta;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		technologie = Util.getBatiment(getActivity().getIntent().getExtras()
				.getString("technologie"));
		final View v = inflater.inflate(R.layout.requirelistlayout_t,
				container, false);
		RequireTArrayAdapter a = new RequireTArrayAdapter(v.getContext(),
				technologie.getRequire().getTechnos());
		setListAdapter(a);
		return v;
	}

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {

		
			Technologie t = technologie.getRequire().getTechnos().get(position).getItem();
			Bundle tb = new Bundle();
			tb.putString("technologie", t.getName());
			Intent i = new Intent(getActivity(), TechnoActivity.class);
			i.putExtras(tb);
			Log.d("RALMN", t.getName());
			startActivity(i);
		super.onListItemClick(l, v, position, id);
	}
}
